package com.fanhang.samples.spring.session.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping(value = "/home")
public class HomeController {

	@RequestMapping(value = "/index", method = { RequestMethod.GET })
	public ModelAndView index() {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("message", "hello，this is the index page of home !");
		modelAndView.setViewName("index");
		return modelAndView;
	}

	@RequestMapping(value = "/welcome", method = { RequestMethod.GET })
	public ModelAndView welcome() {
//		GroovyHello.getName();
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("message", "Welcome to SpringMVC");
		modelAndView.setViewName("simple/welcome");
		return modelAndView;
	}

	@RequestMapping(value = "/ajax", method = { RequestMethod.GET })
	public ModelAndView ajax() {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("ajax/ajax-demo");
		return modelAndView;
	}

}